var atm = {}

atm.ajax =  function (param) {
    $.ajax({
        url : param.url,
        type : param.requestMethod,
        dataType : 'json',
        data : param.data,
        success : function (responseData) {
            if (responseData.code != 1000) {
                alert(responseData.message);
                if (responseData.code == 5000) {
                    window.location.href = '/'
                }
                return;
            }

            //执行用户的success函数
            if (param.success != undefined) {
                param.success(responseData);
            }
        },
        error : function () {
            if (param.error != undefined) {
                param.error();
            }
        }
    });
}

atm.loadMyCard = function () {
    atm.ajax({
        url : '/card/loadMyCard',
        requestMethod : 'GET',
        data : {
        },
        success : function (responseData) {
            let msg = '<option value="no">请选择银行卡</option>';
            let myCards = responseData.data;
            for (let i=0; i<myCards.length; i++) {
                let card = myCards[i];
                msg += '<option value="'+card.cardId+'">'+card.cardNum+'</option>';
            }
            console.log(msg);
            $('#cards').html(msg);
        }
    })
}